home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 November: Tool Chest / Dev.CD Nov 98 TC.toast / Sample Code / Snippets / QuickDraw / Out of This GWorld / Source / events.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-17  |  1.4 KB  |  69 lines  |  [TEXT/CWIE]

  1. #include "out.h"
  2.  
  3. void pollEvents()
  4. {
  5.     EventRecord anEvent;
  6.     WindowPtr   theWindow;
  7.     short       clickArea;
  8.     Rect        screenRect;
  9.     long        sleep;
  10.     
  11.     sleep = 0;
  12.     
  13.     for (;;)
  14.     {
  15.         if (gCurrentMove == START)
  16.             animateCTable();
  17.         
  18.         if (WaitNextEvent (everyEvent, &anEvent, sleep, (RgnHandle) nil))
  19.         {
  20.             if (anEvent.what == mouseDown)
  21.             {
  22.                 clickArea = FindWindow( anEvent.where, &theWindow );
  23.                 
  24.                 if (clickArea == inDrag)
  25.                 {
  26.                     screenRect = (**GetGrayRgn ()).rgnBBox;
  27.                     DragWindow(theWindow, anEvent.where, &screenRect );
  28.                 }
  29.                 else if (clickArea == inGoAway)
  30.                 {
  31.                     if (TrackGoAway( theWindow , anEvent.where ))
  32.                         cleanUp();
  33.                 }
  34.                 
  35.                 else if (clickArea == inMenuBar)
  36.                 {
  37.                     adjustMenus();
  38.                     handleMenu( MenuSelect( anEvent.where ) );
  39.                 }
  40.                 else if (clickArea == inContent)
  41.                 {
  42.                     if (theWindow != FrontWindow())
  43.                         SelectWindow( gWindow );
  44.                 }
  45.             }
  46.             else if (anEvent.what == updateEvt)
  47.             {
  48.                 theWindow = (WindowPtr)anEvent.message;
  49.                 
  50.                 BeginUpdate( theWindow );
  51.                 SetPort( theWindow );
  52.                 drawImage();
  53.                 EndUpdate( theWindow );
  54.             }
  55.             else if (anEvent.what ==  keyDown || anEvent.what == autoKey)
  56.             {
  57.                 if ((anEvent.modifiers & cmdKey) != 0)
  58.                 {
  59.                     adjustMenus();
  60.                     handleMenu( MenuKey( (char)(anEvent.message & charCodeMask) ) );
  61.                 }
  62.             }
  63.             else if (anEvent.what == activateEvt)
  64.             {
  65.                 InvalRect( &gWindow->portRect );
  66.             }
  67.         }
  68.     }
  69. }